package jfox.platform.datadict.bo;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import jfox.platform.datadict.dao.DictCategoryDAO;
import jfox.platform.datadict.entity.DictCategory;
import jfox.platform.function.dao.NodeDAO;
import jfox.platform.function.entity.Node;
import jfox.platform.infrastructure.DataAccessObject;
import jfox.platform.infrastructure.EntityNotExistedException;
import jfox.platform.infrastructure.SuperBO;
@Stateless
@Local
public class DictCategoryBOBean extends SuperBO implements DictCategoryBO {

    @EJB
    DictCategoryDAO dictCategoryDAO;
    
	@Override
	public DataAccessObject getDataAccessObject() {
		return dictCategoryDAO;
	}

	public void deleteCategory(long id) {
		//判断该ENTITY是否被其他对象引用
		DictCategory dictcategory = dictCategoryDAO.getCategoryById(id);
    	if(dictcategory == null){
	            throw new EntityNotExistedException(DictCategory.class, id);
	    }
	    checkEntityReferenced(dictcategory);	     
		dictCategoryDAO.deleteCategory(id);
	}	

	public List<DictCategory> getAllCategory() {		
		return dictCategoryDAO.getAllCategory();
	}
	
	public DictCategory getCategoryByCode(String code) {
		return dictCategoryDAO.getCategoryByCode(code);
	}	
	
	public DictCategory getCategoryById(long id) {
		return dictCategoryDAO.getCategoryById(id);
	}	

	public void newCategory(DictCategory dictCategory) {
		dictCategoryDAO.insertCategory(dictCategory);

	}

	public void updateCategory(DictCategory dictCategory) {
		dictCategoryDAO.updateCategory(dictCategory);

	}

}
